package py.com.fms.fms.session.maintenances;

//External classes imports 
//Java Classes
import java.text.ParseException;
import java.util.*;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;

import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;

import py.com.fms.exception.CommonException;
import py.com.fms.session.ServiceSqlMap;
import py.com.fms.session.WithinHolder;
import py.com.fms.utilities.ConvertAssistant;
import py.com.fms.utilities.DateAssistant;
import py.com.fms.persistence.services.StatusTypeHandlerCallback;

import py.com.fms.fms.bean.PersonAddressBean;
import py.com.fms.fms.bean.PersonBean;
import py.com.fms.fms.bean.PersonDocumentBean;
import py.com.fms.fms.bean.PersonManagerBean;
import py.com.fms.fms.bean.PersonPhoneBean;
import py.com.fms.fms.bean.RefHeadBean;
import py.com.fms.fms.bean.RefDetBean;
import py.com.fms.fms.bean.UsersBean;

import py.com.fms.fms.persistence.services.CountryServices;
import py.com.fms.fms.persistence.services.PersonServices;
import py.com.fms.fms.persistence.services.RefServices;
import py.com.fms.fms.persistence.services.UsersServices;


@SuppressWarnings("unused")
@Name("editRef")
@Scope(ScopeType.SESSION)
public class EditRef {
	
	private FacesMessages facesMessages;
	@Logger
	private Log log;
	@In("#{serviceSqlMap}")
	private ServiceSqlMap sqlMap;
	private boolean editMode;
	private String initVar;
	private Date today = null;
	
	// Task Attendees Attributes 
	@In("#{withinHolder}")
	private WithinHolder aid;
	@In("#{convertAssist}")
	private ConvertAssistant convert;
	private DateAssistant dateAssist;
	@In Credentials credentials;
	@In Identity identity;
	private UsersBean user;
	
	// Attribute used for saving and deleting
	private RefHeadBean refHead;
	private RefHeadBean refHeadUpd;
	private RefDetBean refDet;
	
	// Services
	private RefServices rnSrv;
	private UsersServices usSrv;
	
	// Attribute used for editing or updating
	private RefHeadBean editRefHead;
	private RefDetBean editRefDet;
	private RefHeadBean refHeadToAdd;
	private RefDetBean refDetToAdd;


	// Collection of RefHeadBean
	private Collection<RefHeadBean> allRefHead;
	private Collection<RefDetBean> allRefDet;
	private Collection<RefDetBean> allRefDetToAdd;
	
	// ||GRID COLLECTIONS||
	private List<RefDetBean> refDetCollection;
	private List<RefDetBean> refDetToAddCollection;
	
	// ||REMOVE COLLECTIONS||
	private List<Object> refDetRemove;
	
	// ||SEARCH COLLECTIONS||
	private List<RefHeadBean> refHeadSearch;
	private List<RefDetBean> refDetSearch;
	
//	Necessary Attributes;
	
	//RefHead
	private String headCode;
	private RefHeadBean referenceData;
	
	//Checks
	private boolean checkDet;
	
	//Delete Attributes
	private Object deleteDet;
	
	private String operation = "newRef";
	private String selectedTab = "newRef";
	
	private String updTab = "updRefSub";
	private String selectedTabUpd = "updRefSub";
	
	/**
	 * [[[[[[[[[[[[ Methods ]]]]]]]]]]]] 
	 * [[[[[[[[[[-------------]]]]]]]]]]
	 * @throws CommonException 
	 */

	public void initData() throws CommonException {

		System.out.println("initVar = " + this.getInitVar());

		if ("S".equals(this.getInitVar())) {
			
			this.initBeans();
			this.initServices();
			this.initAssistants();
			this.initCollections();
			this.loadUserData();
			this.loadAllRefHead();
			this.loadAllRefDet();
			
		}
		this.setInitVar(null);
		System.out.println("OUT");
				
	}
	
	// INITIALIZING --------------------]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
	
	public void initBeans(){
				
		if (refHead == null){
			refHead = new RefHeadBean();
		}
		
		if (refDet == null){
			refDet = new RefDetBean();
			refDet.setStatus(true);
		}
		
		if (refHeadToAdd == null){
			refHeadToAdd = new RefHeadBean();
		}
		
		if (refDetToAdd == null){
			refDetToAdd = new RefDetBean();
			refDetToAdd.setStatus(true);
		}
		
		if (refHeadUpd == null){
			refHeadUpd = new RefHeadBean();
		}
		if (editRefHead == null){
			editRefHead = new RefHeadBean();
		}
		
		if (editRefDet == null){
			editRefDet = new RefDetBean();
		}
		
		if (user == null){
			user = new UsersBean();
		}
	}
	
	public void initServices() throws CommonException{
		
		if (rnSrv == null){
			rnSrv = new RefServices(this.sqlMap.getConfig());
		}
		
		if (usSrv == null){
			usSrv = new UsersServices(this.sqlMap.getConfig());
		}
		
	}
	
	public void initAssistants(){
		
		if(aid == null){
			aid = new WithinHolder();
		}
		
		if(convert == null){
			convert = new ConvertAssistant();
		}
		
		if(dateAssist == null){
			dateAssist = new DateAssistant();
		}
		
	}
	
	public void initCollections(){
		if(allRefHead == null){
			allRefHead = new ArrayList<RefHeadBean>();
		}
		if(allRefDet == null){
			allRefDet = new ArrayList<RefDetBean>();
		}
		
		if(refDetCollection == null){
			refDetCollection = new ArrayList<RefDetBean>();
		}
		
		
		if(refDetRemove == null){
			refDetRemove = new ArrayList<Object>();
		}
		
		if(refHeadSearch == null){
			refHeadSearch = new ArrayList<RefHeadBean>();
		}
		
		if(refDetSearch == null){
			refDetSearch = new ArrayList<RefDetBean>();
		}

	}
	
	private void cleanData(){
		
		refHead = null;
		refDet = null;
		refHeadToAdd = null;
		refDetToAdd = null;
		refHeadUpd = null;
		editRefHead = null;
		editRefDet = null;
		user = null;
		rnSrv = null;
		usSrv = null;
		aid = null;
		convert = null;
		dateAssist = null;
		allRefHead = null;
		allRefDet = null;
		refDetCollection = null;
		refDetRemove = null;
		refHeadSearch = null;
		refDetSearch = null;
		
	}
	
	private void loadUserData() throws CommonException{
		if(credentials != null){
			System.out.println("Credenciales Encontradas");
			this.getUser().setUserName(credentials.getUsername());
			System.out.println("User Name: " + this.getUser().getUserName());
			user = usSrv.getUserDataByName(this.getUser().getUserName());
			this.setUser(user);
			System.out.println("User: " + this.getUser());
		}else{	
			System.out.println("Credenciales Nulas");
		}
	}
	
	// Method used for operation changing
	public void changeOperation (ActionEvent event){
		selectedTab = operation;
		this.setInitVar("S");
	}
	
	public void changeUpdTab(String param){
		selectedTabUpd = param;
		this.setInitVar("S");
	}
	
	// Used to load a collection with all data
	private void loadAllRefHead() {
		try {
			this.setAllRefHead(rnSrv.getAllRefHead());
			
		} catch (CommonException e) {
			e.printStackTrace();
		}
	}
	
	private void loadAllRefDet() {
		try {
			this.setAllRefDet(rnSrv.getAllRefDet());
			
		} catch (CommonException e) {
			e.printStackTrace();
		}
	}
	
// METHODS FOR NEW PERSON OPERATION --------------------]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
	
	// Methods for addresses handle ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
	
	public void fillRefDetList(){
		System.out.println("Filling Detail list");
		if (this.getRefDet() == null){
			System.out.println("Entity null");
		}else{
			this.getRefDet().setShortname(convert.convertField(this.getRefDet().getShortname()));
			this.getRefDet().setDescrip(convert.convertField(this.getRefDet().getDescrip()));

			refDetCollection.add(this.getRefDet());
			
			System.out.println(this.getRefDet().getDescrip());
			System.out.println(this.getRefDetCollection());
			System.out.println("------------------------");
			System.out.println("                        ");
			System.out.println("------------------------");
		}
		this.checkDet = false;
		this.setInitVar("S");
		refDet = null;
		
	}
	
	public void detDeleteList(){
		System.out.println("Delete address executed");
		System.out.println("remove: " + this.getDeleteDet());
		System.out.println("check: " + this.isCheckDet());
		if(checkDet == true){
			refDetRemove.add(this.getDeleteDet());
		}else{
			if(checkDet == false){
				refDetRemove.remove(this.getDeleteDet());
			}
			
		}
		
		System.out.println("Remove List:" + refDetRemove);
		System.out.println("------------------------");
		System.out.println("                        ");
		System.out.println("------------------------");
		
	}
	
	public void deleteRefDet(){
		int i;
		int j;	
		if (refDetCollection.isEmpty() || refDetRemove.isEmpty()) {
			System.out.println("Empty List");
		}else{
			
			System.out.println("Elimination Method executed");
			System.out.println("Person Addresses: " + refDetCollection);
			System.out.println("to delete: " + refDetRemove);
			for(i = 0; i<this.refDetRemove.size(); i++){
							
				for(j = 0; j<this.getRefDetCollection().size(); j++){
					String desc= this.getRefDetCollection().get(j).getDescrip();
					System.out.println("desc: " + desc);
					System.out.println("to delete: " + refDetRemove);
					System.out.println("ID: " + desc);
					if((this.refDetRemove.get(i)).equals(desc)){
						this.refDetCollection.remove(j);
					}
				}
			}
				System.out.println("Elements eliminated");
				System.out.println("Details: " + getRefDetCollection());
				System.out.println("to delete: " + refDetRemove);
				System.out.println("------------------------");
											
			
		}
		this.setInitVar(null);
		this.checkDet = false;
		

	}
	
	// SAVING, UPDATING AND DELETING METHODS ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
	// Used for data saving process
	
	public void saveRefHeader() throws ParseException, CommonException{
		System.out.println("en saveRefHeader. antes del try");
		try{
			System.out.println("antes de facesMessages.clear");
//		    this.facesMessages.clear();
			System.out.println("despues de facesMessages.clear");
			
			RefHeadBean newRefHead = new RefHeadBean();
			
			this.today = DateAssistant.getHoleDateTime();
			
			this.setReferenceData(this.getRefHead());
			
			if(this.getReferenceData() == null){
				System.out.println("Header data is null");
			}else{
				System.out.println("Person data: " + this.getReferenceData());
				
			}
			
			if (this.getRefHead() == null) {
				System.out.println("Header Entity is null");
				throw new CommonException("Header doesn't exist");
			}	
			
			// SETTING VALUES
			newRefHead.setCod(convert.convertField(this.getRefHead().getCod()));
			newRefHead.setDescrip(convert.convertField(this.getRefHead().getDescrip()));
			newRefHead.setStartDate(this.today);
			newRefHead.setUserIns(user.getId());
			
			// Sending Bean values trough service for saving
			rnSrv.saveNewRefHead(newRefHead);
			
			this.setHeadCode(convert.convertField(this.getRefHead().getCod()));
			
			System.out.println("CABECERA INSERTADA CORRECTAMENTE");
			
			
		} catch (CommonException e) {
//			this.facesMessages.add(Severity.ERROR, e.getMessage());
			System.out.println("NO SE PUDO INSERTAR LA CABECERA. " + e.getMessage());
			log.error(e);
			this.getLog().debug(e.getMessage());
			throw new CommonException(e.getMessage());
		}finally{
			System.out.println("finally de saveRefHeadre");
		}
	}
	
	public void saveRefDetails() throws ParseException{
		try {

			int i;
			this.today = DateAssistant.getHoleDateTime();
			
			// Retrieving the header id
			if(this.getHeadCode() == null){
				System.out.println("Head Code is NULL");
			}else{
//				this.setReferenceData(convert.getRefHeadData(this.getReferenceData()));
				/*
				 * BRUNO 20100526: El id se busca en el momento del insert por una sequence.
				 */
//				this.setReferenceId(rnSrv.getDetIdByHeadCodeAndShortName(headCode, shortname));

			
				// Printing the header id in the screen 
				System.out.println("DATA: " + this.getReferenceData());
				System.out.println("ID CABECERA: " + this.getHeadCode());
				
				// Verify if the header id is null, if not, process the details.
				if(this.getHeadCode() == null){
					
					System.out.println("ID DE CABECERA NULO");
					
				}else{
					
					RefDetBean newRefDet = new RefDetBean();
					
					if(refDetCollection == null || refDetCollection.isEmpty()){
						
						System.out.println("Lista de detalle vacia");
						throw new CommonException("Debe insertar el detalle");
						
					}else{
						Iterator<RefDetBean> it1 = refDetCollection.iterator();
						while(it1.hasNext()){
								// capturing the next element
								RefDetBean nextDet = it1.next();
								
								// printing values for proof
								System.out.println(nextDet.getDescrip());
								
								// setting bean values
								newRefDet.setHeadCode(this.getHeadCode().toUpperCase());
								newRefDet.setDescrip(nextDet.getDescrip().toUpperCase());
								newRefDet.setShortname(nextDet.getShortname().toUpperCase());
								newRefDet.setStartDate(this.today);
								newRefDet.setUserIns(user.getId());
								newRefDet.setStatus(nextDet.getStatus());
								// saving trough service
								rnSrv.saveRefDet(newRefDet);
						}	
					}
				}
				System.out.println("DETALLE INSERTADO CORRECTAMENTE");
			}
			
		} catch (CommonException e) {
			// this.facesMessages.add(Severity.ERROR, e.getMessage());
			System.out.println("NO SE PUDO INSERTAR EL DETALLE. "
					+ e.getMessage());
			log.error(e);
		}finally{
			this.setRefHead(null);
			this.setRefDet(null);
		}
	}
	
	public String saveNewData() throws ParseException, CommonException {
		System.out.println("Acabamos de entrar a saveNewData()");
		System.out.println("antes de saveRefHeader");
		// Inserting the header
		this.saveRefHeader();
		
		System.out.println("antes de saveRefDetails");
		// Inserting the Details
		this.saveRefDetails();

		System.out.println("antes de this.setInitVar(S)");
		// Setting Initialization VAR
		this.setInitVar("S");
		System.out.println("antes de this.refDetCollection.clear()");
		this.refDetCollection.clear();
		
//		this.initData();
		return null;
	}
	
	// Used to cancel
	public String cancelData() {
//		this.facesMessages.clear();
		this.setInitVar("S");
		return null;
	}
	
	
	// METHODS FOR UPDATE PERSON OPERATION --------------------]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]	

	// SEARCH OPERATIONS ------------------------------------------------------------------------
	
	public void searchRef(RefHeadBean bean) throws CommonException{
		try {
			// Filter 1
			if(bean.getCod() != null){
				bean.setCod(convert.convertField(bean.getCod()));
			}else{
				bean.setCod(null);
			}
			
			// Filter 2
			if(bean.getDescrip() != null){
				bean.setDescrip(convert.convertField(bean.getDescrip()));
			}else{
				bean.setCod(null);
			}


			System.out.println("codigo: " + bean.getCod());
			System.out.println("bean: " + bean);
			this.setRefHeadSearch(rnSrv.getRefSearch(bean));
			
		} catch (CommonException e) {
			e.printStackTrace();
		}finally{
			this.setRefHeadUpd(null);
			this.setInitVar("S");
//			this.initData();
		}
		
	}
	
	public void searchRefDet(RefHeadBean bean) throws CommonException{
		try {
			System.out.println("Buscando detalle");
			this.setRefDetSearch(rnSrv.getRefDetByHeadCode(bean.getCod()));
			
		} catch (CommonException e) {
			e.printStackTrace();
		}finally{
			this.setRefHeadUpd(bean);
			this.setInitVar("S");
//			this.initData();
		}
		
	}
	
	// UPDATE OPERATIONS ------------------------------------------------------------------------
	public void refHeadToEdit(String cod) throws CommonException{
		System.out.println(this.getAllRefHead());
		System.out.println("cod = " + cod);
		for (RefHeadBean bean : this.getAllRefHead()) {
			if(bean.getCod().equals(cod)){
//				bean.setSectorData(rnSrv.getDetById(bean.getSector()));
				this.setEditRefHead(bean);
				System.out.println("Encontro el registro" + this.getEditRefHead());
				return;
			}			
		}
		
	}
	
	public void refDetToEdit(Long id) throws CommonException{
		System.out.println(this.getAllRefDet());
		System.out.println("id = " + id.toString());
		for (RefDetBean bean : this.getAllRefDet()) {
			if(bean.getId().equals(id)){
				this.setEditRefDet(bean);
//				this.getEditAddr().setAddType(rnSrv.getDetById(this.getEditAddr().getIdAddressType()));
				System.out.println(this.getEditRefDet());
				return;
			}			
		}
		
	}
	
	public void refHeadUpd(){
		try {
			this.getEditRefHead().setCod(this.getEditRefHead().getCod().toUpperCase());
			this.getEditRefHead().setDescrip(this.getEditRefHead().getDescrip().toUpperCase());
			rnSrv.updateRefHead(this.getEditRefHead());
			this.searchRef(this.getEditRefHead());
			FacesMessages.instance().add("Datos actualizados con exito");
		} catch (CommonException e) {
//			this.facesMessages.add(Severity.ERROR, e.getMessage());
			System.out.println("NO SE PUDO ACTUALIZAR EL REG. " + e.getMessage());
			FacesMessages.instance().add("NO SE PUDO ACTUALIZAR EL REG. " + e.getMessage());
			log.error(e);
		}
	}
	
	public void refDetUpd(){
		try {
			this.getEditRefDet().setDescrip(this.getEditRefDet().getDescrip().toUpperCase());
			rnSrv.updateRefDet(this.getEditRefDet());
			this.searchRefDet(this.getRefHeadUpd());
			FacesMessages.instance().add("Detalle actualizado con exito");
		} catch (CommonException e) {
//			this.facesMessages.add(Severity.ERROR, e.getMessage());
			System.out.println("NO SE PUDO ACTUALIZAR EL REG. " + e.getMessage());
			FacesMessages.instance().add("NO SE PUDO ACTUALIZAR EL REG. " + e.getMessage());
			log.error(e);
		}
	}
	
	// DELETE OPERATIONS ------------------------------------------------------------------------
	public void refHeadToDelete(String cod){
		System.out.println(this.getAllRefHead());
		for (RefHeadBean bean : this.getAllRefHead()){
			if (bean.getCod().equals(cod)) {
				try {
					
					rnSrv.deleteRefHeadByCode(bean.getCod());
					
				} catch (Exception e) {
//					this.facesMessages.add(Severity.ERROR, e.getMessage());
					System.out.println("NO SE PUDO BORRAR EL REGISTRO. " + e.getMessage());
					FacesMessages.instance().add("NO SE PUDO BORRAR EL REGISTRO. " + e.getMessage());
					log.error(e);
				}
			}
			
		}
		this.setInitVar("S");
	}
	
	public void refDetToDelete(Long id){
		System.out.println(this.getAllRefDet());
		for (RefDetBean bean: this.getAllRefDet()){
			if (bean.getId().equals(id)) {
				try {
					
					rnSrv.deleteRefDetById(bean.getId());
					
				} catch (Exception e) {
//					this.facesMessages.add(Severity.ERROR, e.getMessage());
					System.out.println("NO SE PUDO BORRAR EL REGISTRO. " + e.getMessage());
					FacesMessages.instance().add("NO SE PUDO BORRAR EL REGISTRO. " + e.getMessage());
					log.error(e);
				}
			}
			
		}
		this.setInitVar("S");
	}
	

	// ADD DATA OPERATIONS ------------------------------------------------------------------------
	// [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[------------------------]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
	
	public void loadReDetails(){
		try {
			System.out.println("Loading Reference Details");
			this.setAllRefDetToAdd(rnSrv.getRefDetByHeadCode(this.getRefHeadToAdd().getCod()));
		} catch (CommonException e) {
			e.printStackTrace();
		}
		
	}
	
	public void detToAdd(){
		System.out.println("Filling address list");
		if (this.getRefDetToAdd() == null){
			System.out.println("Entity null");
		}else{
			
			refDetToAddCollection.add(this.getRefDetToAdd());

			System.out.println("------------------------");
		}
		this.setInitVar("S");
		this.setRefDetToAdd(null);
		
	}
	
	public void addrSelected(PersonAddressBean bean){
		System.out.println("Address Selected");
		System.out.println("Selected:" + bean.getSelected());
		System.out.println("[[--------------------]]");
		System.out.println("  ||||||||||||||||||||  ");
		System.out.println("[[--------------------]]");
		
	}
	
	public void detToAddDel(){
	
		if (this.getRefDetToAddCollection().isEmpty()) {
			System.out.println("Empty List");
		}else{
			
			System.out.println("Elimination Method executed");
			
			Iterator<RefDetBean> it = refDetToAddCollection.iterator();
			
			while(it.hasNext()){
				RefDetBean next = it.next();
				System.out.println("Next: " + next);
				System.out.println("Selected: " + next.getSelected());
				if(next.getSelected() == true){
					System.out.println("Next: " + next.getSelected());
					it.remove();
				}
			}

			System.out.println("Elements eliminated");
			System.out.println("------------------------");
											
			
		}
		this.setInitVar(null);
		

	}
	
	public void addRefDetails(){
		try {
			int i;
			// Retrieving the header id
			if(this.getRefHeadToAdd() == null || this.getRefHeadToAdd().getCod().equals(null)){
				System.out.println("Head is null");
			}else{
				System.out.println("Head Data is Correct");
			}

			if(this.getRefHeadToAdd().getCod().equals(null)){
				
				System.out.println("Head cod is null");
			}else{
				if(refDetToAddCollection.isEmpty()){
					
					FacesMessages.instance().add("Debe ingresar datos para agregar a referencias");
				
				}else{
					System.out.println("Head Cod: " + this.getRefHeadToAdd().getCod());
					RefDetBean newRefDet = new RefDetBean();
					
					if(refDetToAddCollection == null || refDetToAddCollection.isEmpty()){
						
						System.out.println("Lista del detalle vacia");
						
					}else{
						Iterator<RefDetBean> it1 = refDetToAddCollection.iterator();
						while(it1.hasNext()){
								// capturing the next element
								RefDetBean nextDet = it1.next();
								
								// printing values for proof
								System.out.println(nextDet.getDescrip());
								
								// setting bean values
								newRefDet.setHeadCode(this.getRefHeadToAdd().getCod().toUpperCase());
								newRefDet.setDescrip(nextDet.getDescrip().toUpperCase());
								newRefDet.setShortname(nextDet.getShortname().toUpperCase());
								newRefDet.setStatus(nextDet.getStatus());
								
								// saving trough service
								rnSrv.saveRefDet(newRefDet);
							
						}
						
					}
					
					
					
					FacesMessages.instance().add("Datos agregados con exito");
				}
			}
			
			
			
		} catch (CommonException e) {
			// this.facesMessages.add(Severity.ERROR, e.getMessage());
			System.out.println("NO SE PUDO INSERTAR EL DETALLE. " + e.getMessage());
			FacesMessages.instance().add("NO SE PUDO INSERTAR EL DETALLE. " + e.getMessage());
			log.error(e);
		}finally{
			this.cleanData();
			this.setInitVar("S");
		}
	}
	
	
	//GETTERS AND SETTERS
	public FacesMessages getFacesMessages() {
		return facesMessages;
	}
	public void setFacesMessages(FacesMessages facesMessages) {
		this.facesMessages = facesMessages;
	}
	public Log getLog() {
		return log;
	}
	public void setLog(Log log) {
		this.log = log;
	}
	public ServiceSqlMap getSqlMap() {
		return sqlMap;
	}
	public void setSqlMap(ServiceSqlMap sqlMap) {
		this.sqlMap = sqlMap;
	}
	public boolean isEditMode() {
		return editMode;
	}
	public void setEditMode(boolean editMode) {
		this.editMode = editMode;
	}
	public String getInitVar() {
		return initVar;
	}
	public void setInitVar(String initVar) {
		this.initVar = initVar;
	}

	public RefHeadBean getRefHead() {
		return refHead;
	}

	public void setRefHead(RefHeadBean refHead) {
		this.refHead = refHead;
	}

	public RefHeadBean getRefHeadUpd() {
		return refHeadUpd;
	}

	public void setRefHeadUpd(RefHeadBean refHeadUpd) {
		this.refHeadUpd = refHeadUpd;
	}

	public RefDetBean getRefDet() {
		return refDet;
	}

	public void setRefDet(RefDetBean refDet) {
		this.refDet = refDet;
	}

	public RefHeadBean getEditRefHead() {
		return editRefHead;
	}

	public void setEditRefHead(RefHeadBean editRefHead) {
		this.editRefHead = editRefHead;
	}

	public RefDetBean getEditRefDet() {
		return editRefDet;
	}

	public void setEditRefDet(RefDetBean editRefDet) {
		this.editRefDet = editRefDet;
	}

	public Collection<RefHeadBean> getAllRefHead() {
		return allRefHead;
	}

	public void setAllRefHead(Collection<RefHeadBean> allRefHead) {
		this.allRefHead = allRefHead;
	}

	public Collection<RefDetBean> getAllRefDet() {
		return allRefDet;
	}

	public void setAllRefDet(Collection<RefDetBean> allRefDet) {
		this.allRefDet = allRefDet;
	}

	public List<RefDetBean> getRefDetCollection() {
		return refDetCollection;
	}

	public void setRefDetCollection(List<RefDetBean> refDetCollection) {
		this.refDetCollection = refDetCollection;
	}

	public List<Object> getRefDetRemove() {
		return refDetRemove;
	}

	public void setRefDetRemove(List<Object> refDetRemove) {
		this.refDetRemove = refDetRemove;
	}

	public List<RefHeadBean> getRefHeadSearch() {
		return refHeadSearch;
	}

	public void setRefHeadSearch(List<RefHeadBean> refHeadSearch) {
		this.refHeadSearch = refHeadSearch;
	}

	public List<RefDetBean> getRefDetSearch() {
		return refDetSearch;
	}

	public void setRefDetSearch(List<RefDetBean> refDetSearch) {
		this.refDetSearch = refDetSearch;
	}

	public String getHeadCode() {
		return headCode;
	}

	public void setHeadCode(String headCode) {
		this.headCode = headCode;
	}

	public RefHeadBean getReferenceData() {
		return referenceData;
	}

	public void setReferenceData(RefHeadBean referenceData) {
		this.referenceData = referenceData;
	}

	public boolean isCheckDet() {
		return checkDet;
	}

	public void setCheckDet(boolean checkDet) {
		this.checkDet = checkDet;
	}

	public Object getDeleteDet() {
		return deleteDet;
	}

	public void setDeleteDet(Object deleteDet) {
		this.deleteDet = deleteDet;
	}

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public String getSelectedTab() {
		return selectedTab;
	}

	public void setSelectedTab(String selectedTab) {
		this.selectedTab = selectedTab;
	}

	public UsersBean getUser() {
		return user;
	}

	public void setUser(UsersBean user) {
		this.user = user;
	}

	public String getSelectedTabUpd() {
		return selectedTabUpd;
	}

	public void setSelectedTabUpd(String selectedTabUpd) {
		this.selectedTabUpd = selectedTabUpd;
	}

	public RefHeadBean getRefHeadToAdd() {
		return refHeadToAdd;
	}

	public void setRefHeadToAdd(RefHeadBean refHeadToAdd) {
		this.refHeadToAdd = refHeadToAdd;
	}

	public RefDetBean getRefDetToAdd() {
		return refDetToAdd;
	}

	public void setRefDetToAdd(RefDetBean refDetToAdd) {
		this.refDetToAdd = refDetToAdd;
	}

	public Collection<RefDetBean> getAllRefDetToAdd() {
		return allRefDetToAdd;
	}

	public void setAllRefDetToAdd(Collection<RefDetBean> allRefDetToAdd) {
		this.allRefDetToAdd = allRefDetToAdd;
	}

	public List<RefDetBean> getRefDetToAddCollection() {
		return refDetToAddCollection;
	}

	public void setRefDetToAddCollection(List<RefDetBean> refDetToAddCollection) {
		this.refDetToAddCollection = refDetToAddCollection;
	}
	
}
